<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.situ.web.entity.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<!-- EL可以从域对象中取出数据 -->
	<%
		// 1.获取普通字符串
		request.setAttribute("name", "lisi");
		session.setAttribute("name", "wangwu");
		// 2.获得Student对象的值
		Student student = new Student(1, "zhangsan", 23, "男");
		session.setAttribute("student", student);
		// 3.获取List<Student> list的值
		List<Student> list = new ArrayList<Student>();
		Student student1 = new Student(1, "张三11", 23, "男");
		Student student2 = new Student(2, "张三22", 23, "男");
		list.add(student1);
		list.add(student2);
		application.setAttribute("list", list);
	%>
	<!-- 1.获取普通字符串 -->
	<%=request.getAttribute("name")%><br/>
	<%=session.getAttribute("name")%><br/>
	${requestScope.name}<br/>
	${sessionScope.name}<br/>
	<!-- EL表达式如果不指定范围，会依从pageContext>request>session>application范围找
		后面大部分情况不需要加范围，直接${名字}
	-->
	${name}
	<hr/>
	<!-- 2.获得Student对象的值 -->
	<%
		// Duplicate local variable student
		Student stu = (Student)session.getAttribute("student");
	%>
	<%=stu.getName()%><br/>
	<%=stu.getGender()%><br/>
	<!-- 在EL表达式中student.name是直接写这个对象的属性名，他会自动调用这个name属性的getName(); -->
	${student.name}--${student.gender}
	
	<hr/>
	<!-- 3.获取List<Student> list的值 -->
	<%
		List<Student> stuList = (List<Student>)application.getAttribute("list");
	%>
	<%=stuList.get(0).getName()%><br/>
	${stuList[0].name}<br/>
	
	${pageContext.request.contextPath}
	${request.contextPath}
	
</body>
</html>